package com.team.teamproject.adapter;

import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by Administrator on 2016/11/5.
 */
public class MyPagerFragmentAdapter extends FragmentPagerAdapter{
    List<Fragment> fragments = new ArrayList<>();
    List<String> titles= new ArrayList<>();
    public MyPagerFragmentAdapter(FragmentManager fm, List<String> titles, List<Fragment> fragments) {
        super(fm);
        this.fragments =fragments;
        this.titles=titles;
    }

    @Override
    public Fragment getItem(int position) {
        return fragments.get(position);
    }

    @Override
    public int getCount() {
        return fragments.size();
    }
    //获取对应的标题
    @Override
    public CharSequence getPageTitle(int position) {
        return titles.get(position);
    }
}
